/*******************************************************************
* ++
* Author        :	ThienTN
* Description   :	Utility.cpp in project HRManage
* 
* Mod. History  :	26/07/2012 - ThienTN
*
* --
*******************************************************************/

#include "Utility.h"


/*
 * Create new list
 */
void CreateList( List *pList )
{
	pList->pHead = pList->pTail = NULL;
}

/*
 * Create new node
 */
Node * CreateNode( CEmployee *pEmployee )
{
	Node *pTemp;
	pTemp = new Node;
	if (pTemp == NULL)
	{
		cout << "Not enough memory!";
		exit(1);
	} 
	else
	{
		pTemp->info = pEmployee;
		pTemp->pNext = NULL;
		pTemp->pPrev = NULL;
		return pTemp;
	}
}

/*
 * Add new node to head
 */
void AddHead( List *pList, Node *pNode )
{
	// List empty
	if (pList->pHead == NULL)
	{
		pList->pHead = pNode;
		pList->pTail = pList->pHead;
	} 
	else // List is not empty
	{
		pNode->pNext = pList->pHead;
		pList->pHead->pPrev = pNode;
		pList->pHead = pNode;
	}
}

/*
 * Menu of program
 */
void Menu()
{
	cout << "--------------HR Manage System------------------" <<endl;
	cout << "\t1.Input Employee" <<endl;
	cout << "\t2.Search Manager" <<endl;
	cout << "\t3.Sort list employee belong to name" <<endl;
	cout << "\t4.Sort list employee belong to employee type" <<endl;
	cout << "\t5.Display list employee" <<endl;
	cout << "\t6.Remove all employee" <<endl;
	cout << "\t0.Quit" <<endl;
}

/*
 * Get Graduated type
 */
std::string GetGradType( int n )
{
	switch (n)
	{
		case BAD:
			return "BAD";
			break;
		case WEAK:
			return "WEAK";
			break;
		case MEDIUM:
			return "MEDIUM";
			break;
		case PRETTY:
			return "PRETTY";
			break;
		case GOOD:
			return "GOOD";
			break;
		case EXCELLENT:
			return "EXCELLENT";
			break;
		default:
			break;
	}
}

/*
 * Get employee type
 */
std::string GetEmpType( int n )
{
	switch (n)
	{
	case STUDENT:
		return "THIS IS STUDENT";
		break;
	case STAFF:
		return "THIS IS STAFF";
		break;
	case MANAGER:
		return "THIS IS MANAGER";
		break;
	default:
		break;
	}
}

/*
 * End action of every case input
 */
void End()
{
	printf("-----------DONE!-------------\n");		
	getch();
	system("cls");
}